#include <cstdio>

#define MAX_SENTENCES 100
#define SENTENCE_LENGTH 102

typedef unsigned int uint;


char sentence[MAX_SENTENCES][SENTENCE_LENGTH];
char *p_sentence[MAX_SENTENCES];


int main ()
{
	uint n, i, incompleted_sentences;

	for (n = 0; fgets (sentence[n], SENTENCE_LENGTH, stdin); ++n)
		p_sentence[n] = sentence[n];
	
	incompleted_sentences = n;
	while (incompleted_sentences)
	{
		for (i = n; i--; )
		{
			char *&p = p_sentence[i];
			if (*p == '\n' || *p == '\0')
				putchar (' ');
			else {
				putchar (*p);
				++p;
				if (*p == '\n' || *p == '\0')
					--incompleted_sentences;
			}
		}
		putchar ('\n');
	}

	return 0;
}